﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ETHotfix {
    /// <summary>
    /// 
    /// </summary>
    [ETModel.Event(ETModel.EventIdType.HotfixInit)]
    public class HotfixInit : ETHotfix.AEvent {
        public override void Run() {

            // 加载热更配置
            ETModel.Game.Scene.GetComponent<ETModel.ResourcesComponent>().LoadBundle("config.unity3d");
            Game.Scene.AddComponent<ConfigComponent, string>("config.unity3d|Config");
            ETModel.Game.Scene.GetComponent<ETModel.ResourcesComponent>().UnloadBundle("config.unity3d");


            var unitConfig = Game.Scene.GetComponent<ConfigComponent>().Get<UnitConfig>(1001);
            Log.Debug($"获取一个测试unityConfig {JsonHelper.ToJson(unitConfig)}");

            //加载热更层自己的全局组件
            Game.Scene.AddComponent<PlayersComponent>();

            Log.Debug("Demo完成热更层的初始化操作,开始初始化界面");

            Game.EventSystem.Run(HotfixEventIdType.InitSceneStart);
        }
    }
}
